module.exports = {
  chainWebpack: config => {
    // 添加worker-loader解析web workers
    config.module
      .rule('worker')
      .test(/\.worker\.js$/)
      .use('babel-loader')
      .loader('babel-loader')
      .end()
      .use('worker-loader')
      .loader('worker-loader')
      .options({
        name: 'workerName.[hash:8].js',
        // publicPath: '/workers/'
        inline: true,
        fallback: false
      })
      .end(); 
    // to avoid cache
    config.module.rule('js').exclude.add(/\.worker\.js$/);
  }
}